const appError = require('../utils/appError');
const RoleModel = require('../models/roleModel');

class CommonService {
  async dictionary() {
    const roles = await RoleModel.find();
    const roleData = roles.map(item => {
      return {
        label: item.name,
        value: item.code
      }
    });

    return {
      "gender": {
        "data": [
          { label: "未知", value: 0 },
          { label: "男", value: 1 },
          { label: "女", value: 2 }
        ],
        "description": "性别信息"
      },
      "status": {
        "data": [
          { label: "禁用", value: 0 },
          { label: "正常", value: 1 }
        ],
        "description": "状态信息"
      },
      "role": {
        "data": roleData,
        "description": "角色信息"
      }
    }
  }
}

module.exports = new CommonService();